﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Enterprise.Infrastructure;
using Enterprise.Model.Manager;
using Enterprise.Service.Manager;
using Enterprise.Service.User;
namespace Enterprise.UI.Web.Modules.Manager
{
    public partial class ReleaseMsg : Enterprise.Service.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnStart();
            }
        }

        private void OnStart()
        {
            UserService uService = new UserService();
            var list = uService.UserList().Where(p =>p.DEPTID == 1).OrderBy(p => p.UORDERBY);
            DeptUser.DataSource = list;
            DeptUser.DataTextField = "UNAME";
            DeptUser.DataValueField = "USERID";
            DeptUser.DataBind();
        }

        protected void Button1_OnClick(object sender, EventArgs e)
        {
            string _note = "操作成功";
            MsgEntity entity = new MsgEntity();
            entity.MsgTUser = (int)Utility.sink(DeptUser.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Int);
            entity.MsgTitle = (string)Utility.sink(ReleaseTitle.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            entity.MsgContent = (string)Utility.sink(ReleaseContent.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Str);
            entity.MsgIsShow = (int)Utility.sink(ReleaseisShow.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Int);
            entity.msgIsAnonymous = (int)Utility.sink(ReleaseIsNim.UniqueID, Utility.MethodType.Post, 0, 0, Utility.DataType.Int);
            entity.MsgFUser = Utility.Get_UserId;
            entity.MsgFIp = Utility.GetIPAddress();
            entity.MsgCreateTime = DateTime.Now;
            entity.DB_Option_Action = "Insert";
            MsgService mService = new MsgService();
            mService.MsgExecute(entity);
            Utility.ShowMsg(this.Page, "OK", this.Tran(_note), "Index.aspx");
        }

    }
}